package com.ruoyi.syf.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.syf.domain.RiskAccidentType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.syf.domain.EscalationConfig;
import com.ruoyi.syf.service.IEscalationConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 上报配置
 *
 * @author yr
 * @date 2024-08-26
 */
@RestController
@RequestMapping("/syf/escalationConfig")
public class EscalationConfigController extends BaseController {
    @Autowired
    private IEscalationConfigService escalationConfigService;

    /**
     * 查询上报配置列表
     */
    @PreAuthorize("@ss.hasPermi('syf:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(EscalationConfig escalationConfig) {
        startPage();
        List<EscalationConfig> list = escalationConfigService.list(escalationConfig);
        return getDataTable(list);
    }

    /**
     * 获取上报配置详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(escalationConfigService.selectById(id));
    }

    /**
     * 修改上报配置
     */
    @PreAuthorize("@ss.hasPermi('syf:config:edit')")
    @Log(title = "上报配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EscalationConfig escalationConfig) {
        return toAjax(escalationConfigService.update(escalationConfig));
    }

    /**
     * 导出上报配置列表
     */
    @PreAuthorize("@ss.hasPermi('syf:config:export')")
    @Log(title = "上报配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EscalationConfig escalationConfig) {
        List<EscalationConfig> list = escalationConfigService.list(escalationConfig);
        ExcelUtil<EscalationConfig> util = new ExcelUtil<EscalationConfig>(EscalationConfig.class);
        util.exportExcel(response, list, "上报配置数据");
    }
}
